{extend name="public/base" /}

{block name="title"}<title>列表</title>{/block}

{block name="pjax_container"}
<style>
tr>th,td{
    text-align: center;
}
 
.content-header>.breadcrumb>li{
    color: #999;
}
.content-header>.breadcrumb>.active{
    color: #666;
}
.content-header{
    height: 51px;
 
}
.btn-primary{
      background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 5px 10px; 
}
.box-primary{
  border-top-color: #ecf0f5 !important;
  border-top-width: 16px;
  
}
.btn-primary:hover{
     background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .9;
    border-radius: 6px !important; 
}
.delete-one{
    background-color: ff4141 !important;
    margin-left: 15px;
    border-radius: 6px;
}
.sreachs{
       background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 7px 15px; 
}
.input-group{
    display: flex;
    flex-wrap: wrap;
} 
.sreachs:hover{
       background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .8;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 7px 15px; 
}
.form-group>label{
height: 100%;
line-height: 30px;
margin-left: 10px;
}
.form-group>input{
    border: none;
    height: 100%;
    border-bottom: 1px solid #ccc;
    
}

</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>企业管理</li>
        <li class="active">企业列表</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">

                <div class="box-tools" style="margin:5px;">
                    <form id="form1" action="{:search_url(['province_id', 'city_id', 'area_id','name','trade_id','manage_id','docking_people','docking_mobile','start_time','mobile','status'])}" method="GET" pjax-search="">
                        <div class="input-group input-group-sm">
                            <input type="hidden" name="page" value="1" />
                            <div class="form-group">
                                <label for="" class=" ">所在地区</label>
                                {include file="form/input_addr"}<br/>
                            </div>

                            <div class="form-group">
                                <label for="" class=" ">企业名称:</label>
                                <input type="text" style="" name="name" class="" value="{:input('get.name')}" placeholder="" />
                                <label for="" class=" ">企业账号</label>
                                <input type="text" style="" name="account" class="" value="{:input('get.account')}" placeholder="" />
                            </div>

                            <div class="form-group">
                                <label for="" class=" ">所属行业</label>
                                <select class="select2" name="trade_id" style="width: 100px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                    <option value="0">全部</option>
                                    {foreach name="$trade_list" item="vo" key="ko"}
                                        {if condition="$vo['status'] == 1"}
                                        <option value="{$ko}" {if condition="input('trade_id') == $ko"}selected{/if}>{$vo['name']}</option>
                                        {/if}
                                    {/foreach}
                                </select>
                                <label for="" class=" ">经营类型</label>
                                <select class="select2" name="manage_id" style="width: 100px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                    <option value="0">全部</option>
                                    {foreach name="$manage_list" item="vo" key="ko"}
                                        {if condition="$vo['status'] == 1"}
                                        <option value="{$ko}" {if condition="input('manage_id') == $ko"}selected{/if}>{$vo['name']}</option>
                                        {/if}
                                    {/foreach}
                                </select>
                                <label for="" class=" ">企业状态</label>
                                <select class="select2" name="status" style="width: 150px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;">
                                    <option value="-1"{if condition="input('status',-1) == -1"}selected{/if}>全部</option>
                                    <option value="0" if condition="input('status',0) == -1"}selected{/if}>冻结或到期关闭</option>
                                    <option value="1" if condition="input('status',1) == -1"}selected{/if}>正常</option>
                                </select>
                            </div>

                            <div class="form-group">
                                <label for="" class=" ">对接人</label>
                                <input type="text" style="" name="docking_people" class="" value="{:input('get.docking_people')}" placeholder="" />
                                <label for="" class=" ">对接人电话</label>
                                <input type="text" style="" name="docking_mobile" class="" value="{:input('get.docking_mobile')}" placeholder="" />
                                <label for="" class=" ">负责人移动电话</label>
                                <input type="text" style="" name="mobile" class="" value="{:input('get.mobile')}" placeholder="" />
                            </div>

                            <div style="width: 247px;">
                                <label style="margin-bottom:0;" for="">启动日期</label>
                                <input class="timepicker" name="start_time" value="{:input('get.start_time')}" placeholder=""  style="margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 28px;border-radius: 3px;" AUTOCOMPLETE="off">
                                <div class="input-group-btn" style="display: inline-block;">
                                    <button type="submit" class="btn btn-default sreachs">
                                        <i class="fa fa-search"></i>查询
                                    </button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="box-header with-border">
                    <div class="pull-left">
                        {:authAction(CONTROLLER_NAME.'/index_edit','create')}
                        {:authAction(CONTROLLER_NAME.'/index_del','delete_all')}
                        <a href="javascript:;" id="explode_company" class="btn btn-sm btn-primary"> 导出</a>
                    </div>

                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>企业名称</th>
                            <th>企业账号</th>
                            <th>所在地区</th>
                            <th>对接人</th>
                            <th>对接人电话</th>
                            <th>所属行业</th>
                            <th>经营类型</th>
                            <th>启动日期</th>
<!--                            <th>月度人均积分</th>-->
<!--                            <th>月度平均奖扣人次</th>-->
                            <th>状态</th>
                            <th>剩余时间</th>
                            <th>操作</th>
                        </tr>
                        {volist name="arr_list" id="v"}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$v.id}" class="minimal checkbox"></td>
                            <td>{$v["name"]}</td>
                            <td>{$v["account"]}</td>
                            <td>
                                {$region_list[$v['province_id']]|default=''}-
                                {$region_list[$v['city_id']]|default=''}-
                                {$region_list[$v['area_id']]|default=''}
                            </td>
                            <td>{$v["docking_people"]}</td>
                            <td>{$v["docking_mobile"]}</td>
                            <td>{$trade_list[$v['trade_id']]['name']??''}</td>
                            <td>{$manage_list[$v['manage_id']]['name']??''}</td>
                            <td>{:date('Y-m-d', $v['start_time'])}</td>

                            <td style="vertical-align:middle">
                                <a href="javascript:void(0);" data-id="{$v['id']}" data-field="status"
                                   data-value="{$v['status']}" data-url="{:url('index_edit', ['id'=>$v['id']])}"
                                   class='editimg fa {if condition="$v.status == 0 "}fa-times-circle text-red{else /}fa-check-circle text-green{/if}'></a>
                            </td>
                            <td>
<?php
                                $r = $v['use_time'] - time();
                                echo time_to_str($r);
?>
                            </td>
                            <td>
                                {:authAction(CONTROLLER_NAME.'/index_edit','edit',['id'=>$v['id']])}
                                <a class="btn btn-primary btn-xs reset" data-id="{$v.id}" href="javascript:;"> 重置企业账号密码</a>
                                <!--<a class="btn btn-primary btn-xs" href="{:url('company/index_add_account', ['id'=>$v['id']])}">添加企业管理员 </a>-->
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(function(){

        $(".select2").select2({language:"zh-CN"});

        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
        $('#explode_company').on('click',function () {
            xls_explode();
        })


        $('.timepicker').datetimepicker({
            format: "{$timepickerFormat | default='YYYY-MM-DD'}",   //YYYY-MM-DD HH:mm:ss
            locale: moment.locale('zh-cn')
        });
        $('.reset').on('click',function () {
            if (!confirm("确定重置？")){return false}
            var id = $(this).attr('data-id');
            var url = "{:url('reset')}";
            $.ajax({
                url:url,
                data:{id:id},
                type:'post',
                success:function (res) {
                    $.amaran({'message':res.msg});
                }
            })
        })
    });

    function xls_explode() {
        window.location.href = "{:url('Company/index')}?" + $('#form1').serialize()+'&export=1';
        return false;
    }

</script>
{/block}
